const {queryDB} = require('./db.js')

/**
 * 添加用户
 */
const testAddUser = ()=>{
    const sql = "INSERT INTO users (username,password,age,sex)VALUES('jack','123456',19,'男')"
    queryDB(sql,(results)=>{
        console.log('执行sql成功' , results);
    })
}

/**
 * 查询所有用户
 */
const testFindUsers = ()=>{
    const sql = "SELECT id,username,password,age,sex FROM users"
    queryDB(sql,(results)=>{
        console.log(results);
    })
}

// testFindUsers()

/**
 * 修改用户
 * 修改用户名为admin的用户用户密码更改为abcd
 */
const testUpdateUser = ()=>{
    const sql = "UPDATE users SET password = 'abcd' WHERE username = 'admin'"
    queryDB(sql,(result)=>{
        console.log(result);
    })
}

// testUpdateUser()

/**
 * 删除用户
 * 删除用户名为jack
 */
const testDeleteUser = ()=>{
    const sql = "DELETE FROM users WHERE username = 'jack' "
    queryDB(sql,(result)=>{
        console.log(result);
        
    })
}

testDeleteUser()